<template>
    <div class="mobile-bind">
        <div class="cPBoxItm-title">
            <div>新密码</div>
            <span class="c-recovery" @click="shut"></span>
        </div>
        <div class="setPublic-tipBox">
            <span class="setPublic-tipCont"></span>
            <span class="setPublic-tipWarning" v-if="tip">
                    <span class="setPublic-tipIcon">&#xe64a;</span>
                    <span class="setPublic-tipErr">{{content}}</span>
            </span>
        </div>
        <div class="newPassword">
            <div class="newPassword-input">
                <span>新密码</span>
                <div><input class="Password-input" v-model="pwd1" minlength="6"  maxlength="20" type="password" placeholder="支持6-20位字母加数字非特殊字符"></div>
            </div>
            <div class="newPassword-input">
                <span>确认新密码</span>
                <div><input class="Password-input"  v-model="pwd2" minlength="6"  maxlength="20" type="password"><span class="Password-icon">&#xe649;</span></div>
            </div>
        </div>
        <div class="personal-information-select">
            <div class="personal-information-determine cPBox-pas nice-btn-lBlue" @click="next">下一步</div>
            <div class="personal-information-cancel  c-recovery cancel-btn-ordinary" @click="shut">取消 </div>
        </div>
    </div>
</template>
<script>
    export default{
        data(){
            return{
                tip:false,
                pwd1:'',
                pwd2:'',
                content:''
            }
        },
        methods:{
            next:function () {
                let patt=/^[0-9a-zA-Z]*$/g;
                let patt1=/^[0-9a-zA-Z]*$/g;
                if(this.pwd1!=''&&this.pwd2!=''){
                    if(patt.test(this.pwd1)&&patt1.test(this.pwd2)){
                        if(this.pwd1==this.pwd2){
                            $.ajax({
                                type:"get",
                                url:"/employee_upwd",
                                dataType:'jsonp',
                                data:{
                                    usrPwd:this.pwd2
                                },
                                success:(data)=>{
                                    if(data.success.opResult==0){
                                        this.$emit('scu');
                                    }else if(data.success.opResult==2){
                                        this.content='服务器异常';
                                        this.tip=true;
                                        setTimeout(()=>{
                                            this.tip=false;
                                        },1500);
                                    }else if(data.success.opResult==3){
                                        this.content='请输入新密码';
                                        this.tip=true;
                                        setTimeout(()=>{
                                            this.tip=false;
                                        },1500);
                                    }else if(data.success.opResult==4){
                                        this.content='新旧密码相似';
                                        this.tip=true;
                                        setTimeout(()=>{
                                            this.tip=false;
                                        },1500);
                                    }
                                }
                            })
                        }else {
                            this.content='前后密码不一致';
                            this.tip=true;
                            setTimeout(()=>{
                                this.tip=false;
                            },1500);
                        }
                    }else {
                        this.content='密码格式错误';
                        this.tip=true;
                        setTimeout(()=>{
                            this.tip=false;
                        },1500);
                    }
                }else{
                    this.content='密码不能为空';
                    this.tip=true;
                    setTimeout(()=>{
                        this.tip=false;
                    },1500);
                }
            },
            shut:function () {
                this.$emit('thisKg')
            }
        }
    }
</script>
<style scoped>
    .newPassword{
        height:81px;
        display:block !important;
    }
    .setPublic-tipBox {
        color: white;
        font-size: 12px;
        padding: 25px 0px 7px 12px;
        height: 16px;
    }
</style>